﻿// (c) Norbert Huffschmid
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.

using System;
using System.Globalization;
using System.Windows.Data;

namespace SpinDotters.Widgets.Converter
{
    /// <summary>
    /// Converter to scale a fontsize value by a given factor
    /// </summary>
    public class FontSizeConverter : IValueConverter
    {
        /// <summary>
        /// Convert fontsize value
        /// </summary>
        /// <param name="value">Fontsize value to convert</param>
        /// <param name="targetType">Must be integer</param>
        /// <param name="parameter">Scale factor</param>
        /// <param name="culture">Not applicable</param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if ((value.GetType() != typeof(double)) ||
                (targetType != typeof(double)))
                throw new ArgumentException("Invalid FontSizeConverter arguments");

            return (double)value * Double.Parse((string)parameter, CultureInfo.InvariantCulture);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

    }
}
